<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<%@include file="../common/mastertop.jsp"%>
<div id="seach" class="mainInner"> 
<p class="page-title">
	<i class="locale-icon"></i> <span>当前位置 : </span> <span
		class="cur-page-title">安装管理</span> <span>· 安装列表</span>
</p>
 <form class="form-inline clearfix"   id="seachform" action="${pageContext.request.contextPath}/admin/setup/index"	method="post">
 	<div class="filter-warp rect-fff clearfix">
		<div class="form-group col-xs-6 col-lg-4">
				<span class="form-label">门店</span> <select name="shopId"
					id="shopId" class="form-control form-control-260">
					<option value=""
						<c:if test="${model.shopId==null}">selected="selected"</c:if>>全部</option>
					<c:forEach items="${model.shopInfos}" var="lo" varStatus="itemStatus">
						<option value="${lo.id}"
							<c:if test="${model.shopId==lo.id}">selected="selected"</c:if>>${lo.shopName}</option>
					</c:forEach>
				</select>
		</div>
		
		<div class="form-group col-xs-6 col-lg-4">
				<span class="form-label">安装状态</span> <select name="status"
					id="status" class="form-control form-control-260">
					<option value="" <c:if test="${model.status==null}">selected="selected"</c:if>>全部</option>
					<option value="1" <c:if test="${model.status==1}">selected="selected"</c:if>>申请安装中</option>	
					<option value="2" <c:if test="${model.status==2}">selected="selected"</c:if>>待安装</option>	
					<option value="3" <c:if test="${model.status==3}">selected="selected"</c:if>>已安装</option>	
					<option value="4" <c:if test="${model.status==4}">selected="selected"</c:if>>已拒绝</option>	
				</select>
		</div>

		<div class="form-group col-xs-6 col-lg-4">
			<span class="form-label">客户姓名</span> <input type="text"
				class="form-control form-control-260" 
				name="realName" value="${model.realName}" >
		</div>
			
		<div class="col-xs-12  text-center">
			<button type="button" class="btn runmi-primary search-btn"
				onclick="seach()">查询</button>
		</div>
	</div>
	
	<div class="rect-fff table-warp">
		<div class="table-scroll">


			<table>
				<tr>
					<th>客户姓名</th>
					<th>销售门店</th>					
					<th>安装地址</th>
					<th>状态</th>
					<th>申请时间</th>
					<th>预计安装时间</th>
					<th>实际安装时间</th>
					
				</tr>
				<c:forEach items="${model.items}" var="item" varStatus="itemStatus">
					<tr  id="row_${item.id}">
						
						<td>${item.customer_name}</td>
						<td>${item.shop_name}</td>
						<td>${item.prov_name}-${item.city_name}-${item.area_name}-${item.address}</td>
						
						<c:choose>
							<c:when test="${item.status == '1'}">
								<td  align="center" class="cdr fw7">申请安装中 </td>
							</c:when>
							<c:when test="${item.status == '2'}">
								<td  align="center" class="cdr fw7">待安装</td>
							</c:when>
							<c:when test="${item.status == '3'}">
								<td  align="center" class="cdr fw7">已安装</td>
							</c:when>
							<c:when test="${item.status == '4'}">
								<td  align="center" class="cdr fw7">拒绝</td>
							</c:when>
							<c:otherwise>
								<td  align="center" class="cdr fw7"></td>
							</c:otherwise>
						</c:choose>
						<td><fmt:formatDate value="${item.create_time}"  type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td>
						<td><fmt:formatDate value="${item.expect_date}"  type="both" pattern="yyyy-MM-dd"/></td>
						<td><fmt:formatDate value="${item.setup_time}"  type="both" pattern="yyyy-MM-dd"/></td>

					</tr>
				</c:forEach>
			</table>
		</div>
		
		<vp:pages cpage="${model.cpage}" totalCount="${model.totalCount}"
			pageSize="${model.pageSize}" />
	</div>
 
 </form>  
 </div>
<div id="edit" style="display:none;width: 100%;height: 100%;overflow:hidden;position:absolute;left:0;top:0;right:0;bottom:0;">
        <iframe id="editFrame" width="100%" height="100%"  frameborder="0" border="0" scrolling="auto"></iframe>
 </div>
  <script type="text/javascript">
	function seach(){
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
	    $("#btnOk").attr("disabled", "disabled");	  
	    var objform = document.getElementById('seachform');
	    objform.submit();
	}	
	function confirm(id,type){
		if(type==1){
			layer.confirm('确认要停用此门店吗', {
				  title :'确认停用',
				  btn: ['确认','取消'] //按钮
				}, function(){
					sendOpTo(id,type);
				}, function(){
				  
				});	
		}else{
			sendOpTo(id,type);
		}

	}
	function sendOpTo(id,type){
		layer.load(1, {shade: [0.5,'#fff']});
		var postData="shopId=" + id + "&opType=" + type;
		 $.ajax({
	            type: "POST",
	            url: "changeStatus",
	            data: postData,
	            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	            async: true, // 同步  true 异步。默认是异步
	            dataType: 'json',
	            error: function(resultdata) {
	            	layer.closeAll();
	            },
	            success: function(resultdata) {
	            	layer.closeAll();
	                if(resultdata.returnCode=="0000"){               	
	                	layer.alert('操作成功',{icon: 1}, function(){
	                		layer.closeAll();
	                	 	 oksubmit();
	                	});
	                }else{
	                	layer.alert(resultdata.returnMessage);
	                }
	            }
	        });
	}
	function createCode(id,type){
		layer.load(1, {shade: [0.5,'#fff']});
		var postData="shopId=" + id + "&type=" + type;
		 $.ajax({
	            type: "POST",
	            url: "createCode",
	            data: postData,
	            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	            async: true, // 同步  true 异步。默认是异步
	            dataType: 'json',
	            error: function(resultdata) {
	            	layer.closeAll();
	            },
	            success: function(resultdata) {
	            	layer.closeAll();
	                if(resultdata.returnCode=="0000"){               	
	                	layer.alert('操作成功',{icon: 1}, function(){
	                		layer.closeAll();
	                	 	 oksubmit();
	                	});
	                }else{
	                	layer.alert(resultdata.returnMessage);
	                }
	            }
	        });
	}
	
    function editReturn() {
       layer.closeAll();
       oksubmit();
    }
    function closeAll() {
        layer.closeAll();
     }
    function showCode(url,title){
    	var ishttps = 'https:' == document.location.protocol ? true: false;
    	var domainUrl="";
    	if(ishttps){
    		domainUrl="https" +url;
    	}else{
    		domainUrl="http" +url;
    	}
    	//alert(url);
		layer.open({
			  type: 2,
			  title: title,
			   area: ['460px', '480px'],
			   content: domainUrl //iframe的url
	      }); 
    }
    function edit(id){
		var domainUrl="edit?shopId=" + id;
		layer.open({
			  type: 2,
			  title: '门店',
			   area: ['600px', '330px'],
			   content: domainUrl //iframe的url
	      }); 
		// $('#wrap').hide();
	    // $('#editFrame').attr("src", domainUrl);
	    // $('#edit').show(); 
	}
	function editReturn() {
		  layer.closeAll();
		  $('#seach').show();
	      $('#editFrame').attr("src", "");
	      $('#edit').hide();
	      oksubmit();
		}

	</script>
<%@include file="../common/masterbottom.jsp"%>
